﻿#set($uid = $domain.UniqueID)   ## the domain unique id
<table id="selected$uid" class="grid-view-as-field">
    <thead>
        <tr class="with-border">
            <th>
                #set($searchUri = $uri.Parse("$domain.Type/Search/All"))
                #set($searchResponse = $app.ExecuteProcess($searchUri, null))
                <select id="select$uid" name="select$uid">
                    <option />
                    #foreach($item in $searchResponse.Result)
                        #if(!$domain.Domains.ContainsValue($item.Value))
                        <option value="$item.Value">$item.Instance</option>
                        #end
                    #end
                </select>
                <input type="button" class="button" value="$app.GetLocalizationString($domain, "Add")" onclick='addSelected("$uid", "select$uid", "selected$uid");' />
            </th>
            <th style="vertical-align:middle;">
                #if($domain.CanWrite)
                    <input type="button" class="button" value="$app.GetLocalizationString($domain, "Remove Selected")" onclick='removeSelected("$uid", "select$uid", "selected$uid");' />
                #end
            </th>
        </tr>
    </thead>
    <tbody>
        #if($domain.Domains.Count > 0)
            #foreach($child in $domain.Domains)
                #if($child.Instance)
                     <tr class="with-border">
                        <td>$child.Instance<input type="hidden" name="$domain.UniqueID" value="$child.Value" /></td>
                        <td style='text-align:right;'>#if($domain.CanWrite)<input type="checkbox" class="checkbox" />#end</td>
                     </tr>
                #end
            #end
        #end
    </tbody>
</table>